package cn.qiyu5522.controller;

import cn.qiyu5522.annotation.WebLog;
import cn.qiyu5522.domain.entity.ResponseResult;
import cn.qiyu5522.domain.entity.User;
import cn.qiyu5522.service.BlogLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * ClassName: BlogLoginController
 * Package: cn.qiyu5522.controller
 * Description:
 *
 * @Author: Tonkey
 * @Create：2024/4/11-20:35
 * @Version: v1.0
 */


@Api(tags = "博客相关接口")
@RestController
public class BlogLoginController {



    @Resource
    private BlogLoginService blogLoginService;


    @WebLog(description = "用户登录")
    @ApiOperation(value = "用户登录",notes = "根据用户名和密码进行登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "user", value = "用户实体类")
    })
    @PostMapping("/login")
    public ResponseResult login(@Validated @RequestBody User user){
        return blogLoginService.login(user);
    }


    @ApiOperation(value = "用户注销",notes = "用户退出登录")
    @WebLog(description = "用户注销")
    @PostMapping("/logout")
    public ResponseResult logout(){
        return blogLoginService.logout();
    }
}
